package com.yin.myproject;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * VM Options : -XX:+TraceClassLoading
 *
 * @author Eason
 * @create 2018-03-30 14:24
 **/
public class ClassAcquireDemo {
    public static void main(String[] args) {
        try {
            //通过Class.forName获取Class对象
            Class clazz = Class.forName("com.alibaba.fastjson.JSON");
            System.out.println("The class name is : " + clazz.getName());

            //通过实例对象获取Class对象
            JSONObject jsonObject = new JSONObject();
            Class clazz1 = jsonObject.getClass();
            System.out.println("The class name is : " + clazz1.getName());

            //通过Class字面量
            Class clazz2 = JSONArray.class;
            System.out.println("The class name is : " + clazz2.getName());
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }


}
